import 'package:flutter/material.dart';

class ListViewCase extends StatelessWidget {
const ListViewCase({ Key? key }) : super(key: key);

// 封装函数获取整个列表
List<Widget> getList(){
List<Widget> list = [];
for (var i = 0; i < 10; i++) {
  list.add(Container(
    color: Colors.cyan,
    width: double.infinity,
    height: 100,
    alignment: Alignment.center,
    margin: EdgeInsets.all(10),
    child: Text('我是第${i+1}个',style: TextStyle(color: Colors.white,fontSize: 20)),
  ));
 
}
 return list;
}

  @override
  Widget build(BuildContext context){
    return ListView(
      children: getList(),
    );
  }
}